package models

import (
	. "zhhuiyan/authority"
	"fmt"
	"github.com/astaxie/beego/orm"
	"time"
)

type Model struct {
	Id     int64 `form:"-"`
	Object *Object `orm:"rel(fk)"`
}

func (model Model) String() string {
	return fmt.Sprintf("{Id:%d, Object:Object{id:%d,Name:%s}}", model.Id, model.Object.Id, model.Object.Name)
}

type Classify struct {
	Id                   int64 `form:"-"`
	Title                string `orm:"unique"form:"-"`
	Summary              string `form:"description,textarea,简介："`
	Object            *Object `orm:"rel(fk)"`
}
type Image struct {
	Id                     int64 `form:"-"`
	Url                    string `orm:"unique"form:"-"`
	Thumbnail              string `orm:"unique"form:"-"`
	Title                  string `orm:"unique"form:"title,,标题："`
	Author                 string `form:"author,,作者："`
	CreateTime             time.Time   `form:"description,textarea,创作时间："`
	Description            string `form:"description,textarea,介绍："`
	Classifies             []*Classify `orm:"rel(m2m)"form:"-"`

	Object  *Object `orm:"rel(fk)"`
}

func (model Image) String() string {
	return fmt.Sprintf("{Id:%d, Object:Object{id:%d,Name:%s}，Url:s%}", model.Id, model.Object.Id, model.Object.Name, model.Url)
}

type Article struct {
	Id                     int64 `form:"-"`
	Title                  string `orm:"unique"form:"title,,标题："`
	CreateTime             time.Time   `form:"description,date,创作时间："`
	Summary                string `form:"description,textarea,简介："`
	Content                string `orm:"unique"form:"content,textarea,内容："`
	Author                 string `form:"author,,作者："`
	KeyWords               string `form:"keyWords,,关键词："`
	Classifies             []*Classify `orm:"rel(m2m)"form:"-"`
	Object             *Object `orm:"rel(fk)"`
}

func init() {
	orm.RegisterModel(new(Model), new(Classify), new(Image), new(Article))
}


